<template>
  <div class="item">
    <div class="title" :style="{ background: color }">{{ title }}</div>
    <el-popover v-if="currentPoint" placement="top-start" width="200" trigger="hover">
      <div v-for="point in currentPointData" :key="point.id" class="point-box">
        <div class="point-title">
          <i class="el-icon-warning" style="color: red"></i>
          {{ point.department }}
        </div>
        <div class="point-content">
          {{ point.content }}
        </div>
      </div>
      <circleTemp slot="reference" :color="color"></circleTemp>
    </el-popover>
    <circleTemp v-else :color="color"></circleTemp>
    <div class="line" v-if="showLine">
      <div class="line-left" :style="lineStyle(blocking)"></div>
      <div class="line-right" :style="arrowStyle(blocking)">
        <i class="el-icon-caret-right"></i>
      </div>
    </div>
    <div class="time" :style="{ background: bgColor }">
      <div v-if="currentPoint">进行中</div>
      <div v-else-if="startTime" class="time-item">
        <span>{{ startTime }}</span>
        <el-divider direction="vertical" style="height: 6px"></el-divider>
        <span>{{ endTime }}</span>
      </div>
      <div v-else>--</div>
    </div>
  </div>
</template>

<script>
import circleTemp from "./circleTemp.vue";
export default {
  name: "flowNodeTemp",
  components: { circleTemp },
  props: [
    "color",
    "title",
    "showLine",
    "blocking",
    "bgColor",
    "startTime",
    "endTime",
    "currentPoint",
    "currentPointData"
  ],
  data() {
    return {};
  },
  methods: {
    lineStyle(blocking) {
      return {
        borderColor: blocking ? "#B8B8B8" : "#4D82FF",
      };
    },
    arrowStyle(blocking) {
      return {
        color: blocking ? "#B8B8B8" : "#4D82FF",
      };
    },
  },
};
</script>

<style scoped lang="less">
.item {
  flex: 1;
  text-align: center;
  position: relative;
  height: 120px;
}

/deep/.el-divider--vertical {
  margin: 0;
}

.line {
  width: 80%;
  height: 14px;
  position: absolute;
  top: 35%;
  left: 60%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 0;
  overflow: hidden;

  .line-left {
    border-bottom: 1px dashed;
    flex: 1;
  }

  .line-right {
    width: 12px;
    text-align: center;
  }
}

.title {
  color: white;
  width: 106px;
  height: 30px;
  border-radius: 8px;
  line-height: 30px;
  margin: 0 auto 5px auto;
}

.time {
  border-radius: 8px;
  width: 150px;
  height: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto;

  .time-item {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  span {
    line-height: normal;
  }
}

.point-box {
  font-size: 13px;

  .point-title {
    font-weight: bold;
  }

  .point-content {
    padding: 5px 0;
  }
}
</style>